package com.ygqh.baby.mapper;

import com.ygqh.baby.ao.QueryInfo;
import com.ygqh.baby.ao.ReturnStatus;
import com.ygqh.baby.ao.ReturnType;
import com.ygqh.baby.model.*;
import com.ygqh.baby.po.YgReturnOrder;
import com.ygqh.baby.po.YgReturnOrderExample;
import org.apache.ibatis.annotations.Param;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import java.util.Map;

public interface YgReturnOrderMapper {
    int countByExample(YgReturnOrderExample example);

    int deleteByExample(YgReturnOrderExample example);

    int deleteByPrimaryKey(Long id);

    int insert(YgReturnOrder record);

    int insertSelective(YgReturnOrder record);

    List<YgReturnOrder> selectByExample(YgReturnOrderExample example);

    YgReturnOrder selectByPrimaryKey(Long id);

    int updateByExampleSelective(@Param("record") YgReturnOrder record, @Param("example") YgReturnOrderExample example);

    int updateByExample(@Param("record") YgReturnOrder record, @Param("example") YgReturnOrderExample example);

    int updateByPrimaryKeySelective(YgReturnOrder record);

    int updateByPrimaryKey(YgReturnOrder record);

    int countSuper(@Param("q") String q, @Param("username") String username, @Param("returnType") ReturnType returnType, @Param("returnCode") String returnCode,
                   @Param("startDate") Date startDate, @Param("endDate") Date endDate, @Param("orderId") Long orderId,
                   @Param("returnStatus") ReturnStatus returnStatus, @Param("expressCode") String expressCode, @Param("productName") String productName);

    List<YgReturnOrder> selectSuper(@Param("queryInfo") QueryInfo queryInfo, @Param("q") String q, @Param("username") String username,
                                    @Param("returnType") ReturnType returnType, @Param("returnCode") String returnCode, @Param("startDate") Date startDate,
                                    @Param("endDate") Date endDate, @Param("orderId") Long orderId, @Param("returnStatus") ReturnStatus returnStatus,
                                    @Param("expressCode") String expressCode, @Param("productName") String productName);

    List<YgOrderModel> selectOrderListForReturn(@Param("queryInfo") QueryInfo queryInfo, @Param("userId") Long userId,
                                                @Param("limitDate") Date limitDate, @Param("platformNo") String platformNo);

    YgOrderInfoModel selectOrderInfo(@Param("orderId") Long orderId, @Param("userId") Long userId, @Param("status") String status);

    YgReturnOrder findDetailById(@Param("id") Long id);

    YgReturnOrderInfoModel selectReturnOrderInfo(@Param("returnCode") String returnCode, @Param("userId") Long userId);

    YgReturnOrder findReturnOrderDetail(@Param("id") Long id);

    List<YgReturnOrderModel> selectReturnList(@Param("queryInfo") QueryInfo queryInfo, @Param("userId") Long userId,
                                              @Param("platformNo") String platformNo);

    List<YgReturnOrder> selectOrderForComplete(@Param("limitDate") Date limitDate);

    int returnOrderForCompleteTask(@Param("returnCodes") List<String> returnCodes);

    List<OrderReturnInfo> selectReOrder4Cancel(@Param("limitDate") Date limitDate);

    int updateReOrderForCancel(@Param("returnCodes") List<String> returnCodes);

    List<Map<String, Object>> selectReturnOrderReport(@Param("startDate") Date startDate, @Param("endDate") Date endDate,
                                                      @Param("returnType") String returnType, @Param("productName") String productName);

    YgReturnOrder selectReturnOrderMoneryById(@Param("id") Long id);

    List<CheckReturnModel> existReturn(@Param("orderId") Long orderId, @Param("sourceSkuIds") List<Long> sourceSkuIds);

    BigDecimal residualRefundPrice(@Param("orderId") Long orderId);

    List<ResidualRefundSku> residualRefundSku(@Param("orderId") Long orderId);

    List<YgReturnOrder> selectByReturnStatusHasDetail(@Param("startDate") Date startDate,
                                                      @Param("endDate") Date endDate,
                                                      @Param("returnCode") String returnCode,
                                                      @Param("returnType") ReturnType returnType,
                                                      @Param("supplierId") Long supplierId,
                                                      @Param("afterSales") Boolean afterSales,
                                                      @Param("returnReasonType") String returnReasonType,
                                                      @Param("returnStatus") ReturnStatus... returnStatus);

    BigDecimal residualRefundPriceOnlyPaid(@Param("orderId") Long orderId);

    List<YgReturnOrder> selectByOrderIdsHasDetail(@Param("orderIds") List<Long> orderIds, @Param("returnType") ReturnType returnType,
                                                  @Param("returnStatus") ReturnStatus... returnStatus);

    List<YgReturnOrder> selectReturnBySupplierId(@Param("queryInfo") QueryInfo queryInfo, @Param("supplierId") Long supplierId,
                                                 @Param("returnType") ReturnType returnType, @Param("returnCode") String returnCode, @Param("startDate") Date startDate,
                                                 @Param("endDate") Date endDate, @Param("orderId") Long orderId, @Param("returnStatus") ReturnStatus returnStatus,
                                                 @Param("expressCode") String expressCode, @Param("productName") String productName);

    int countReturnBySupplierId(@Param("supplierId") Long supplierId, @Param("returnType") ReturnType returnType, @Param("returnCode") String returnCode,
                                @Param("startDate") Date startDate, @Param("endDate") Date endDate, @Param("orderId") Long orderId,
                                @Param("returnStatus") ReturnStatus returnStatus, @Param("expressCode") String expressCode, @Param("productName") String productName);

    List<Map<String, Object>> selectSendOrderBySupplier(@Param("supplierId") Long supplierId, @Param("startDate") Date startDate,
                                                        @Param("endDate") Date endDate);

    List<Map<String, Object>> selectReturnBySupplier(@Param("supplierId") Long supplierId, @Param("startDate") Date startDate, @Param("endDate") Date endDate);

    List<Long> selectOrderIdsByReturn(@Param("startDate") Date startDate, @Param("endDate") Date endDate, @Param("returnType") ReturnType returnType,
                                      @Param("returnStatus") ReturnStatus... returnStatus);

    int updateChangeSend(@Param("changeList") List<YgReturnOrder> changeList);

    List<String> selectExistsReturnCode(@Param("list") List<String> returnCodeList);

    int insertBatch(@Param("list") List<YgReturnOrder> insertList);

    int updateWdtOrderCode(@Param("list") List<String> returnCodeList);

    int updateReturnStatusByReturnCode(@Param("list") List<YgReturnOrder> updateOrderList);

    List<YgReturnOrder> selectChangeDetailBySendTime(@Param("startDate") Date startDate, @Param("endDate") Date endDate,
                                                     @Param("supplierId") Long supplierId, @Param("afterSales") Boolean afterSales);

    List<Map<String, Object>> selectReturnedInfoBySupplier(@Param("startDate") Date startDate, @Param("endDate") Date endDate,
                                                           @Param("supplierId") Long supplierId, @Param("afterSales") Boolean afterSales);

    List<YgReturnOrder> selectDetailByReturnCodeList(@Param("list") List<String> returnCodeList);
}
